

wx.cloud.init({
  env: 'dongyingyin-3khfy'
})

var util = require('../../utils/util.js');
const db = wx.cloud.database();
let text = ""
let imgUrls = ""
let abs = ""
Page({
  data: {
    "time":"",
    "tapmessage":[],
    "ziyou":[],
    "openid":"",
    "userInfo": [],
    isShow: false,
    isShowbindtap: false,
    userput: [],
    title:"",
    imgUrls: [],
    abs:[{
      
      latitude: 23.633000,
      longitude: 113.678150,
    }
      


    ],
    // imgUrls1: [ {
    //   _id	:	4,
    //   id: 3,
    //   latitude: 23.631000,
    //   longitude: 113.677450,
    //   iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
    //   width: 30,
    //   height: 30,
    //   callout: {
    //     content: " 请点击地图位置选取想要上传的标点位置",
    //     padding: 10,
    //     display: 'ALWAYS',
    //     name: 'zhongdananfnag',
    //     textAlign: 'center',
    //     borderRadius: 10,
    //     color: '#ffffff',


    //     bgColor: '#ffe74b'
    //   }

    // },],
    latitude1:'',
    longitude1:'',
    latitude:'',
    longitude:'',
    markers1: [
      
      {
      id: 1,
      latitude: 23.633100,
      longitude: 113.685116,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      scale: 17,
      name: 'zhongdananfnag',

    },

    {
      id: 3,
      latitude: 23.631000,
      longitude: 113.677450,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 教学楼1-4",
        padding: 10,
        display: 'ALWAYS',
        name: 'zhongdananfnag',
        textAlign: 'center',
        borderRadius: 10,
        color: '#ffffff',


        bgColor: '#ffe74b'
      }

    },

    {
      id: 4,
      latitude: 23.630900,
      longitude: 113.678550,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 实验楼1-3",
        padding: 10,
        display: 'ALWAYS',
        textAlign: 'center',
        color: '#ffffff',


        bgColor: '#ffe74b',
        borderRadius: 10

      }
    },
    {
      id: 5,
      latitude: 23.63360,
      longitude: 113.676800,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: "xxxx会议",
        padding: 10,
        display: 'ALWAYS',
        color: '#ffffff',
        bgColor: '#ffe74b',
        borderRadius: 10,
        textAlign: 'center',

      }

    },
    {
      _id: "dhjsbdhs",
      id: 6,
      latitude: 23.634550,
      longitude: 113.677840,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 行政楼a2",
        padding: 10,
        display: 'ALWAYS',
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        textAlign: 'center'
      }

    },
    {
      id: 7,
      latitude: 23.632700,
      longitude: 113.678740,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 图书馆",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },

    {
      id: 8,
      latitude: 23.634700,
      longitude: 113.679340,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: "  中饭   （3、4）",
        padding: 10,
        display: 'ALWAYS',
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        textAlign: 'center'
      }


    },
    {
      id: 9,
      latitude: 23.632300,
      longitude: 113.674900,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 西操",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },
    {
      id: 11,
      latitude: 23.63410,
      longitude: 113.682300,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 东饭",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },
    {
      id: 12,
      latitude: 23.63390,
      longitude: 113.678540,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 教学楼5-7",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },

    {
      id: 13,
      latitude: 23.63415,
      longitude: 113.680140,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 教学楼8-9",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },
    {
      id: 14,
      latitude: 23.633300,
      longitude: 113.680140,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 教学楼10-11",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },
    {
      id: 15,
      latitude: 23.632900,
      longitude: 113.680140,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 实验楼4",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },
    {
      id: 17,
      latitude: 23.631500,
      longitude: 113.680140,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 综合楼",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },
    {
      id: 16,
      latitude: 23.630500,
      longitude: 113.680350,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 商业中心",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },
    {
      id: 17,
      latitude: 23.630780,
      longitude: 113.679650,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: " 快递中心",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    },
    {
      id: 10,
      latitude: 23.632300,
      longitude: 113.681240,
      iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      width: 30,
      height: 30,
      callout: {
        content: "  东操",
        padding: 10,
        borderRadius: 10,
        color: '#ffffff',
        bgColor: '#ffe74b',
        display: 'ALWAYS',
        textAlign: 'center'
      }


    }
  ],
    tempMarkers1: [
      {
        id:0,
        latitude: 23.633711,
        longitude: 113.678424,
        iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      //   width: 30,
      //   height: 30,
      content:"新冠疫苗活动"
      },
      {
        id:1,
        latitude:  23.632872,
        longitude:  113.679131,
        iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      //   width: 30,
      //   height: 30,
      content:"校内游乐活动"
      },
     

    ],
    tempMarkers2: [
      {
        id:2,
        latitude: 23.633711,
        longitude: 113.678424,
        iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
        width: 30,
        height: 30,
      },
 

    ],
    curLatit:'',
    curLong:'',
    markers: [
      // {
      //   "id": 4,
      //   "latitude": 23.634303,
      //   "longitude": 113.677606,
      //   "iconPath": "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
      //   "width":30,
      //   "height":30,
      //   "callout": {
      //     "content": "新冠疫苗接种志愿者",
      //     "padding": 10,
      //     "borderRadius": 10,
      //     "color": "#ffffff",
      //     "bgColor": "#ffe74b",
      //     "display": "ALWAYS",
      //     "textAlign": "center"
      //   }
      // },

        // {
        //   // id:2,
        //   latitude: 23.633711,
        //   longitude: 113.678424,
        //   iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
        //   width: 30,
        //   height: 30,
        //  },

       

         {
                id: 3,
                latitude: 23.631000,
                longitude: 113.677450,
                iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
                width: 30,
                height: 30,
                callout: {
                  content: " 请点击地图位置选取想要上传的标点位置",
                  padding: 10,
                  display: 'ALWAYS',
                  name: 'zhongdananfnag',
                  textAlign: 'center',
                  borderRadius: 10,
                  color: '#ffffff',
        
        
                  bgColor: '#ffe74b'
                }
        
              },
      ],
      justforlx:[  {
                id: 12,
                latitude: 23.04440475326635,
                longitude: 113.42568098387233,
                iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
                width: 30,
                height: 30,
                callout: {
                  content: "心之所向",
                  padding: 10,
                  display: 'ALWAYS',
                  name: 'zhongdananfnag',
                  textAlign: 'center',
                  borderRadius: 10,
                  color: '#ffffff',
        
        
                  bgColor: '#ffe74b'
                },
 


              },],
    url: "../../img/樱桃.png"
  },



  input1: function (m, index) {
   
    const {imgUrls1} =this.data
    console.log("之前",this.data.imgUrls1)

    const {curLatit}=this.data
    const{curLong}=this.data
    // var tempMarkers1 = [];
    // console.log(m)
    imgUrls1.forEach((m, index) => {
      var info = {
        id: '',
        iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
        // 标记点图片，常见有蓝色点你懂得 
        latitude: '', // 每一个被标点的纬度 
        longitude: '', // 每一个被标点的经度 
        width: 20, // 使用图标的宽度 
        height: 20, // 使用图标的高度 
        title: "", // 点击标记点显示的title 
        callout: {
          content: " ",
          padding: 10,
          display: 'ALWAYS',
          name: '',
          textAlign: 'center',
          borderRadius: 10,
          color: '#ffffff',
  
  
          bgColor: '#ffe74b'
        }


      };
      info.id = index;
      info.latitude = m.latitude;
      info.longitude = m.longitude;
      info.callout.content = m.callout.content;
      imgUrls1.push(info)
      this.setData({
        latitude: curLatit,
        longitude: curLong,
        markers: imgUrls1
      })
      console.log("之后",this.data.imgUrls1)

      console.log(this.data.latitude)
      console.log(this.data.longitude)
    })
  },

  uploaddata:function(e){
    var that =this 
    wx.setStorage({
      key:"markers",
      data:that.data.markers
      

    })
  },


  input2: function (index) {
  //  获取markers数组的信息
    const {userput} =this.data
    const {title}=this.data
    // console.log("之前",this.data.imgUrls1)
  // 将data中点击的经纬度获取到函数之中
    const {curLatit}=this.data
    const{curLong}=this.data

    // var tempMarkers1 = [];
    // console.log(m)

  //  将经纬度添加到数组之中执行
  //  或者直接用函数来执行


    // 下一步就是开始循环markers数组的内容
    // 因为只有一个点，所以不需要循环，把foreach去除
    // imgUrls1.forEach((m, index) => {
      var info = {
        id: '',
        iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
        // 标记点图片，常见有蓝色点你懂得 
        latitude: '', // 每一个被标点的纬度 
        longitude: '', // 每一个被标点的经度 
        width: 20, // 使用图标的宽度 
        height: 20, // 使用图标的高度 
        title: "你成功了！", // 点击标记点显示的title 
        callout: {
          content: " ",
          padding: 10,
          display: 'ALWAYS',
          name: '',
          textAlign: 'center',
          borderRadius: 10,
          color: '#ffffff',
          bgColor: '#ffe74b'
        }


      };
      info.id = index;
      info.latitude = curLatit;
      info.longitude = curLong;
      info.callout.content= title;
      userput.push(info)
      this.setData({
        latitude: curLatit,
        longitude: curLong,
        markers: userput
      })
      // console.log("之后",this.data.imgUrls1)
      console.log("之后",this.data.markers)

   
      // 下面的小括号也要一起去除
    // })
  },






  input3: function (m, index) {
   
    const {abs} =this.data
    console.log("之前",this.data.abs)

    const {curLatit}=this.data
    const{curLong}=this.data
    // var tempMarkers1 = [];
    // console.log(m)
    abs.forEach((m, index) => {
      var info = {
        id: '',
        iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
        // 标记点图片，常见有蓝色点你懂得 
        latitude: '', // 每一个被标点的纬度 
        longitude: '', // 每一个被标点的经度 
        width: 20, // 使用图标的宽度 
        height: 20, // 使用图标的高度 
        title: "", // 点击标记点显示的title 
        callout: {
          content: " ",
          padding: 10,
          display: 'ALWAYS',
          name: '',
          textAlign: 'center',
          borderRadius: 10,
          color: '#ffffff',
          bgColor: '#ffe74b'
        }


      };
      info.id = index;
      info.latitude = m.latitude;
      info.longitude = m.longitude;
      // info.callout.content = m.callout.content;
      abs.push(info)
      this.setData({
        // latitude: curLatit,
        // longitude: curLong,
        markers:abs
      })
      console.log("之后",this.data.abs)

      console.log(this.data.latitude)
      console.log(this.data.longitude)
    })
  },

  input4: function (index) {
    //  获取markers数组的信息
      // const {userput} =this.data
      const {title}=this.data
      // console.log("之前",this.data.imgUrls1)
    // 将data中点击的经纬度获取到函数之中
      const {curLatit}=this.data
      const{curLong}=this.data
      const{markers}=this.data
         var userput = [];
  
      // var tempMarkers1 = [];
      // console.log(m)
  
    //  将经纬度添加到数组之中执行
    //  或者直接用函数来执行
 
  
      // 下一步就是开始循环markers数组的内容
      // 因为只有一个点，所以不需要循环，把foreach去除
      markers.forEach((m, index) => {
        var info = {
          id: 1,
          iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
          // 标记点图片，常见有蓝色点你懂得 
          latitude: '', // 每一个被标点的纬度 
          longitude: '', // 每一个被标点的经度 
          width: 20, // 使用图标的宽度 
          height: 20, // 使用图标的高度 
          title: "你成功了！", // 点击标记点显示的title 
          callout: {
            content: " ",
            padding: 10,
            display: 'ALWAYS',
            name: '',
            textAlign: 'center',
            borderRadius: 10,
            color: '#ffffff',
            bgColor: '#ffe74b'
          }
  
  
        };
        // info.id = index;
        info.latitude = curLatit;
        info.longitude = curLong;
        info.callout.content= title;
        userput.push(info)
        this.setData({
          latitude: curLatit,
          longitude: curLong,
          id:this.data.id,
          markers: userput
        })
        // console.log("之后",this.data.imgUrls1)
        console.log("之后",this.data.markers)
  
     
        // 下面的小括号也要一起去除
      })
    },

  
  input: function (index) {
  
    var tempMarkers = [];
    // res.forEach((m, index) => {


      var info = {
        id: 0,
        iconPath: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/dingdian.png?sign=8a288a66356343428164e98489926eb9&t=1620890661",
        // 标记点图片，常见有蓝色点你懂得 
        latitude: '23.634303', // 每一个被标点的纬度 
        longitude: '113.677606', // 每一个被标点的经度 
        width: 20, // 使用图标的宽度 
        height: 20, // 使用图标的高度 
        title: "新冠疫苗接种志愿者", // 点击标记点显示的title 
      };
      info.id = index;
      info.latitude =  '23.634303';
      // info.latitude = m.latitude;
      info.longitude = '113.677606';
      // info.longitude = m.longitude;
      // info.title = address;
      // info.title = m.address;
      tempMarkers.push(info)
      this.setData({
        latitude: 23.634303,
        // latitude: curLatit,
        longitude: 113.677606,
        // longitude: curLong,
        markers:[...this.data.markers, ...tempMarkers],
       
      })
      console.log(this.data.latitude)
      console.log(this.data.longitude)
    // })
  },


  onReady: function (options) {
    console.log("res",options)
    this.includePoints()
  },

  onShow: function (options) {
    console.log("res1",options)
    this.mapCtx = wx.createMapContext('map');
    this.setData({
      title: getApp().globalData.title,
      userInfo: getApp().globalData.userInfoapp
   
    })
  },
  tap: function () {
    wx.getLocation({
      type: 'gcj02',
      success: (res) => {
        const latitude = res.latitude
        const longitude = res.longitude
      }
    })
  },
  

  getdatapoint: function () {
    var that = this
    db.collection('swiper').get({
      success: function (res) {
        console.log(res)
       
        that.setData({
          abs:res.data[3]

        })
      
       

      }
    })
  },
  updatepoint: function () {
   





  },



  onLoad: function (options) {
    var that = this
    console.log("res2",options)
    var TIME = util.formattime(new Date());

    that.setData({
      time:TIME,
    
    });
    db.collection('swiper').get({
      success: function (res) {
        console.log(res)
        console.log(res.data[1])
        console.log(res.data[0].imgUrls)
        that.setData({
          imgUrls2: res.data[0].imgUrls,
          // markers: [...that.data.markers, ...res.data[1]],
          // markers: res.data[1],
          imgUrls: res.data[1]

        })
        console.log("chenggong", res.data[1].callout)

      }
    })
    // 上传数据库中的标点坐标
  
      




    // 获取数据库中的标点坐标
    // db.collection('markers').get().then(res => {
    //   console.log("asds", res.data[0].markers)
    //   that.setData({
    //     markers: res.data[0].markers
    //   })
    // })
  },


  markertranslation: function () {
    var that = this;
      // console.log("tianqi",that.dathata.geo_location)
      wx.request({
        url: 'https://apis.map.qq.com/tools/poimarker?type=0&marker=coord:23.630900,113.678550;title:中大南方;addr:广州市从化区温泉镇882号',
        
        // city:this.data.region[1],
        data:{
          
          referer:'mapin中南',

         
          key:'2OPBZ-2IFK6-KNQST-E7D2G-XHXLJ-RKBFC'
        },
        success:function(res){
          console.log(res);
        
        }
      })
    },


  setInput(e) {
    var inputVal = e.detail.value;
    this.setData({
      inputVal
    });
  },
  serchData() {
    this.qqmapsdk.search({
      keyword: this.data.inputVal,
      success: res => {
        var markers = this.data.markers;
        res.data.map((item, index) => {
          markers.push(this.setMark(item.location, index));
        })
        this.mapContext.moveToLocation();
        this.setData({
          markers
        });
      }
    });
  },
  setMark(location, index) {
    var temp = {
      iconPath: "../../img/樱桃.png",
      width: 30,
      height: 30,
      id: index,
      latitude: location.lat,

    };
    return temp;
  },

  includePoints: function () {
    this.mapCtx.includePoints({
      padding: [10],
      points: [{
        latitude: 23.628054,
        longitude: 113.675566
      }, {
        latitude: 23.635794,
        longitude: 113.682373
      }]
    })
  },

 justforlx: function () {
   console.log("ok")
   var that = this
  getApp().globalData.justforlx =that.data.justforlx

  },
  onChangeAddress: function () {
    var _page = this;
    wx.chooseLocation({
      success: function (res) {
        _page.setData({
          chooseAddress: res.name
        });
      },
      fail: function (err) {
        console.log(err)
      }
    });
  },

  denglu: function () {
     wx.navigateTo({
                 url: '../../pages/end/end'
              })
  },


  reverseGeocoder(location) {
    this.qqmapsdk.reverseGeocoder({
      location,
      success: res => {
        console.log(res);
      }
    });
  },

  handleTextInput(e){
console.log(e)
this.setData({
  title:e.detail.value
})
 getApp().globalData.title =this.data.title

  },

  inputpage(e){
    if (this.data.userInfo == undefined ||JSON.stringify(this.data.userInfo)=='{}') {

      this.getopenid()
      this.getUserProfile()


      
      // wx.navigateTo({
      //   url: '../end3/end3',
        
      //   success: (result) => {},
      //   fail: (res) => {},
      //   complete: (res) => {},
      // })
    } else {
      wx.navigateTo({
        url: '../index3/index3',
        
        success: (result) => {},
        fail: (res) => {},
        complete: (res) => {},
      })
    }
    },

    getopenid() {
      var that = this
      wx.cloud.callFunction({
  
        name: "getopenid",
        success(res) {
          console.log("获取openid成功", res.result.openid)
          console.log(res)
          that.setData({
            openid: res.result.openid
  
          })
          console.log()
          getApp().globalData.openid = that.data.openid
  
  
        },
        fail(res) {
          console.log("获取openid成功", res)
        }
      })
    },
  
  
  
    getUserProfile(e) {
      var that = this
      console.log(e)
      // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认
      // 开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
      if (getApp().globalData.openid == null) {
        wx.getUserProfile({
          desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
          success: (res) => {
            console.log(res)
            // wx.setStorage({
            //   key:"userInfo",
            //   data:"res.userInfo"
            // })
            that.setData({
              userInfo: res.userInfo,
              hasUserInfo: true
            })
            wx.setStorage({
              key:"userInfo",
              data:res.userInfo
            })
            getApp().globalData.userInfo = res.userInfo

            wx.navigateTo({
              url: '../index3/index3',
              
              success: (result) => {},
              fail: (res) => {},
              complete: (res) => {},
            })
            
  
          }
        })
      } else {
        console.log("有了", e)
  
        this.setData({
  
          hasUserInfo: true
        })
        wx.navigateTo({
          url: '../index3/index3',
          
          success: (result) => {},
          fail: (res) => {},
          complete: (res) => {},
        })
      }
    },
  
    bindtapfangda(e){
      console.log(e)
     this.setData({  
     })
      },

      
  bindtapsuoxaio(e){
    console.log(e)
   this.setData({  
   })
    },

  bindtap2(e){
    console.log(e)
   this.setData({  
   })
    },

  bindtap(e){
    console.log(e)
    console.log("现在的makers信息",this.data.markers)
  console.log("坐标点",e.detail.latitude.toPrecision(8))
  console.log("坐标点",e.detail.longitude.toPrecision(9))

  // if (e.detail.latitude.toPrecision(8) >= 23.624712 ||e.detail.latitude.toPrecision(8) <=23.626270 ||e.detail.longitude.toPrecision(9)>=113.702625 ||e.detail.longitude.toPrecision(9)<=113.668597) {

    if (e.detail.latitude.toPrecision(8) >= 23.610708&&e.detail.latitude.toPrecision(8) <=23.645270&&e.detail.longitude.toPrecision(9)>=113.671732&&e.detail.longitude.toPrecision(9)<=113.686597) {
      console.log("在范围点内",e)
    this.setData({
      curLatit:e.detail.latitude.toPrecision(8),
      curLong:e.detail.longitude.toPrecision(9)    
     })
     this.input4()
    

  } else {
    console.log("出界打灭",e)

    wx.showToast({
      title: '那里不可以',
      icon: 'error',
      duration:500
    })
  
  }

 wx.setStorage({
  key:"markers",
  data:this.data.markers
  
})



 

  },
  bindMakertap: function (event) {
    console.log(event, '11111');
    this.setData({
      isShowbindtap: true,
      
    })


    
    getApp().globalData.curLatit = this.data.curLatit
    getApp().globalData.curLong = this.data.curLong
  },

  

  bindtap3: function (event) {
    console.log(event, '11111');
    this.setData({
      isShowbindtap: false,
    })
  },

  bindMakertap1: function (event) {
    console.log(event, '11111');
    this.setData({
      isShow: true,
    })
  },

  

  bindtap31: function (event) {
    console.log(event, '11111');
    this.setData({
      isShow: false,
    })
  },

  clear: function (){
    this.setData({
      markers: [],
    })

  },

  ziyou: function (){
    var  that = this; 

      //  获取数据库中的标点坐标
    db.collection('ziyouMarker').get().then(res => {
      console.log("asds",res)
      console.log("文字信息",res.data[0].markers[0].callout.content)
      that.setData({
        markers: res.data[0].markers,
        ziyou:res.data[0].markers[0].callout.content
      })
    })

  },

  zhiyuan: function (){
    var  that = this; 

      //  获取数据库中的标点坐标
    db.collection('zhiyuanMarker').get().then(res => {
      console.log("asds",res)
      console.log("文字信息",res.data[0].markers)
        var src_list=res.data[0].markers
             var judge=res.data[0].markers["length"]
     console.log("length",judge)
            console.log("src_list",src_list)

    // src_list.forEach((item,judge)=>{
    //             var ziyou=Date.now()+"_"+judge;
    //   //           that.uploadImg(fileName,item)
    //           })


      that.setData({
        markers: res.data[0].markers,
        ziyou:src_list
      })
    })

  },

  jiangzuo: function (){
    var  that = this; 

      //  获取数据库中的标点坐标
    db.collection('jiangzuoMarker').get().then(res => {
      console.log("asds",res)
      that.setData({
        markers: res.data[0].markers,
        ziyou:res.data[0].markers[0].callout.content
      })
    })

  },

  shetuan: function (){
    var  that = this; 

      //  获取数据库中的标点坐标
    db.collection('shetuanMarker').get().then(res => {
      console.log("asds",res)
      that.setData({
        markers: res.data[0].markers,
        ziyou:res.data[0].markers[0].callout.content
      })
    })

  },



  clearup: function (){
    wx.removeStorageSync("markers"),
      // wx.removeStorageSync("markers")
    
      this.setData({
        // markers: wx.clearStorageSync("markers"),
        markers: []
      })
     
   

  },

  ckMap(e){
    var temp = {
      iconPath: "/assets/img/local.png",
      id: 0,
      width: 25,
      height: 25,
      ...e.detail
    }
    var markers = this.data.markers;
    markers.push(temp);
    this.setData({
      markers
    }, () => {
      var data = {
        ...e.detail
      };
      this.mapCtx.moveToLocation(data)
    })
  }
})

